import { ItemData } from "../../resource/info/ItemData";
import { EquipmentItemDataUtil } from "./EquipmentItemDataUtil";
import { Cache } from "../../cache/Cache";
import { ArrayUtil } from "../../../../com/gengine/utils/ArrayUtil";
import { ECategory } from "../../../../Message/Public/ECategory";
import { EEquip } from "../../../../Message/Public/EEquip";
import { EDressPos } from "../../../../Message/Public/EDressPos";
type int = number;
//class EquimentContrastUtil
    
    export  class EquimentContrastUtil
    {
        

        public static getContrastValueArray(arg1: ItemData, arg2: ItemData, arg3: Boolean=true): Array<any>
        {
            var loc4=null;
            var loc5=null;
            var loc7=null;
            var loc8=false;
            var loc9=0;
            var loc10=null;
            var loc1=[];
            var loc2=new EquipmentItemDataUtil(arg1);
            var loc3=new EquipmentItemDataUtil(arg2);
            if (arg3) 
            {
                loc4 = loc2.getBasePropArray(true);
                loc5 = loc3.getBasePropArray(true);
            }
            else 
            {
                loc4 = loc2.getAddtionalArray(true);
                loc5 = loc3.getAddtionalArray(true);
            }
            var loc6=0;
            while (loc6 < loc5.length) 
            {
                loc7 = loc5[loc6] as Map<any, any> /* flash.utils.Dictionary */;
                loc8 = false;
                loc9 = 0;
                while (loc9 < loc4.length) 
                {
                    if ((loc10 = loc4[loc9] as Map<any, any> /* flash.utils.Dictionary */)["name"] == loc7["name"]) 
                    {
                        loc1.push(loc7["value"] - loc10["value"]);
                        loc8 = true;
                        break;
                    }
                    ++loc9;
                }
                if (!loc8) 
                {
                    loc1.push(loc7["value"]);
                }
                ++loc6;
            }
            return loc1;
        }

        public static getContrastValueArrayByItemCode(arg1: int): Array<any>
        {
            var loc4=null;
            var loc6=null;
            var loc1=Cache.instance.pack.backPackCache.getItemByCode(arg1);
            if (!loc1) 
            {
                loc1 = new ItemData(arg1);
            }
            var loc2=EquimentContrastUtil.getSameDressingOnByItemData(loc1);
            var loc3;
            var loc5=(loc3 = new EquipmentItemDataUtil(loc1)).getAllPropArray(true, true);
            if (loc2) 
            {
                loc6 = (loc4 = new EquipmentItemDataUtil(loc2)).getAllPropArray(true, true);
            }
            return ArrayUtil.merge(loc5, loc6, "type", "value", ArrayUtil.MergeType_Sub);
        }

        public static getSameDressingOnByItemData(arg1: ItemData): ItemData
        {
            var loc1=null;
            var loc4=0;
            var loc2=arg1.category;
            var loc3=arg1.itemInfo.item.type;
            if (loc2 == ECategory._ECategoryEquip) 
            {
                if (loc3 != EEquip._EEquipWeapon) 
                {
                    if (loc3 != EEquip._EEquipHelmet) 
                    {
                        if (loc3 != EEquip._EEquipShoulder) 
                        {
                            if (loc3 != EEquip._EEquipClothes) 
                            {
                                if (loc3 != EEquip._EEquipWristlet) 
                                {
                                    if (loc3 != EEquip._EEquipGloves) 
                                    {
                                        if (loc3 != EEquip._EEquipBelt) 
                                        {
                                            if (loc3 != EEquip._EEquipPants) 
                                            {
                                                if (loc3 != EEquip._EEquipShoes) 
                                                {
                                                    if (loc3 != EEquip._EEquipRing) 
                                                    {
                                                        if (loc3 != EEquip._EEquipJewelry) 
                                                        {
                                                            if (loc3 != EEquip._EEquipFashion) 
                                                            {
                                                                if (loc3 != EEquip._EEquipFashionWeapon) 
                                                                {
                                                                    if (loc3 != EEquip._EEquipHeartLock) 
                                                                    {
                                                                        if (loc3 != EEquip._EEquipWing) 
                                                                        {
                                                                            if (loc3 != EEquip._EEquipFootPrint) 
                                                                            {
                                                                                if (loc3 != EEquip._EEquipBubble) 
                                                                                {
                                                                                    if (loc3 != EEquip._EEquipSurround) 
                                                                                    {
                                                                                        if (loc3 != EEquip._EEquipWaistBelt) 
                                                                                        {
                                                                                            if (loc3 != EEquip._EEquipElf) 
                                                                                            {
                                                                                                if (loc3 != EEquip._EEquipHarmMedalDeeper) 
                                                                                                {
                                                                                                    if (loc3 == EEquip._EEquipHarmMedalLower) 
                                                                                                    {
                                                                                                        loc4 = (EDressPos._EDressPosHarmMedalLower - 1);
                                                                                                    }
                                                                                                }
                                                                                                else 
                                                                                                {
                                                                                                    loc4 = (EDressPos._EDressPosHarmMedalDeeper - 1);
                                                                                                }
                                                                                            }
                                                                                            else 
                                                                                            {
                                                                                                loc4 = (EDressPos._EDressPosElf - 1);
                                                                                            }
                                                                                        }
                                                                                        else 
                                                                                        {
                                                                                            loc4 = (EDressPos._EDressPosWaistBelt - 1);
                                                                                        }
                                                                                    }
                                                                                    else 
                                                                                    {
                                                                                        loc4 = (EDressPos._EDressPosSurround - 1);
                                                                                    }
                                                                                }
                                                                                else 
                                                                                {
                                                                                    loc4 = (EDressPos._EDressPosBubble - 1);
                                                                                }
                                                                            }
                                                                            else 
                                                                            {
                                                                                loc4 = (EDressPos._EDressPosFootPrint - 1);
                                                                            }
                                                                        }
                                                                        else 
                                                                        {
                                                                            loc4 = (EDressPos._EDressPosWing - 1);
                                                                        }
                                                                    }
                                                                    else 
                                                                    {
                                                                        loc4 = 15;
                                                                    }
                                                                }
                                                                else 
                                                                {
                                                                    loc4 = (EDressPos._EDressPosFashionWeapon - 1);
                                                                }
                                                            }
                                                            else 
                                                            {
                                                                loc4 = 13;
                                                            }
                                                        }
                                                        else 
                                                        {
                                                            loc4 = 7;
                                                        }
                                                    }
                                                    else 
                                                    {
                                                        loc4 = 9;
                                                    }
                                                }
                                                else 
                                                {
                                                    loc4 = 5;
                                                }
                                            }
                                            else 
                                            {
                                                loc4 = 4;
                                            }
                                        }
                                        else 
                                        {
                                            loc4 = 3;
                                        }
                                    }
                                    else 
                                    {
                                        loc4 = 12;
                                    }
                                }
                                else 
                                {
                                    loc4 = 11;
                                }
                            }
                            else 
                            {
                                loc4 = 2;
                            }
                        }
                        else 
                        {
                            loc4 = 1;
                        }
                    }
                    else 
                    {
                        loc4 = 0;
                    }
                }
                else 
                {
                    loc4 = 6;
                }
                loc1 = EquimentContrastUtil.getItemByVIndex(loc4);
            }
            return loc1;
        }

        /* internal  */static getItemByVIndex(arg1: int): ItemData
        {
            var loc1=Cache.instance.pack.rolePackCache.getAllItems();
            var loc2=arg1;
            var loc3=arg1;
            switch (loc3) 
            {
                case 7:
                {
                    loc2 = 8;
                    break;
                }
                case 8:
                {
                    loc2 = 7;
                    break;
                }
                case 9:
                {
                    loc2 = 10;
                    break;
                }
                case 10:
                {
                    loc2 = 9;
                    break;
                }
            }
            if (loc2 != arg1) 
            {
                if (loc1[arg1] == null) 
                {
                    return loc1[arg1];
                }
                if (loc1[loc2] == null) 
                {
                    return loc1[loc2];
                }
            }
            return loc1[arg1] as ItemData;
        }
    }
